package com.n5x.model.user;

import com.n5x.model.AbstractModel;

import java.math.BigDecimal;
import java.util.Date;

public class UserTransactionRecord extends AbstractModel {

    private UserTransactionRecord() {
    }

    public UserTransactionRecord(String fkUser, String transactionNumber, Method method, TransactionType type, BigDecimal money) {
        this.fkUser = fkUser;
        this.method = method.name();
        this.transactionType = type.name();
        this.transactionNumber = transactionNumber;
        this.money = money;
        this.setCreateTime(new Date());
        this.setLastUpdateTime(new Date());
        this.setDisable(Boolean.TRUE);
    }

    /**
     * 交易类型
     */
    public enum TransactionType {
        充值, 消费, 赠送;

        public static TransactionType getTransactionType(Integer ordinal) {
            if (ordinal == null) return null;
            int size = TransactionType.values().length;
            if (ordinal < 0 || ordinal > size - 1) return null;
            return TransactionType.values()[ordinal];
        }
    }

    /**
     * 交易方式
     */
    public enum Method {
        现金, 微信, 支付宝, 余额, 优惠券;

        public static Method getMethod(Integer ordinal) {
            if (ordinal == null) return null;
            int size = Method.values().length;
            if (ordinal < 0 || ordinal > size - 1) return null;
            return Method.values()[ordinal];
        }
    }


    /**
     * 关联用户
     */
    private String fkUser;

    /**
     * 交易方式
     */
    private String method;

    /**
     * 交易类型
     */
    private String transactionType;

    /**
     * 交易号码
     */
    private String transactionNumber;

    /**
     * 交易金额
     */
    private BigDecimal money = new BigDecimal(0);

    /**
     * 备注
     */
    private String note = "";

    public String getFkUser() {
        return fkUser;
    }

    public void setFkUser(String fkUser) {
        this.fkUser = fkUser;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getTransactionType() {
        return transactionType;
    }

    public void setTransactionType(String transactionType) {
        this.transactionType = transactionType;
    }

    public String getTransactionNumber() {
        return transactionNumber;
    }

    public void setTransactionNumber(String transactionNumber) {
        this.transactionNumber = transactionNumber;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public String getNote() {
        return note;
    }

    public UserTransactionRecord setNote(String note) {
        this.note = note;
        return this;
    }
}